<?php

namespace common\queues;

use common\models\db\CustomBankCard;
use wodrow\yii2wtools\tools\Model;
use yii\base\BaseObject;
use yii\queue\JobInterface;

class CustomSetSettlementCard extends BaseObject implements JobInterface
{
    public $customBankCardId;

    public function execute($queue)
    {
        $model = CustomBankCard::findOne($this->customBankCardId);
        if ($model->status != CustomBankCard::STATUS_DEFAULT) {
            $model->status = CustomBankCard::STATUS_DEFAULT;
            if (!$model->save()) {
                throw new \Exception(Model::getModelError($model));
            }
        }
    }
}